package com.apes.fico.engine.service;


import com.apes.fico.engine.model.VoucherOwnerConfig;
import com.apes.fico.engine.repository.VoucherOwnerConfigRepository;
import com.apes.framework.api.DomainService;
import com.apes.framework.plugin.esb.api.SimpleRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * @ClassName VoucherOwnerConfigService
 * @Description TODO
 * @Author cxm
 * @Date 2022/2/17 16:51
 * @Version 1.0
 **/
@Service("voucherOwnerConfigService")
public class VoucherOwnerConfigService extends DomainService {

    @Autowired
    private VoucherOwnerConfigRepository voucherOwnerConfigRepository;

    /**
     * 保存
     *
     * @param request
     * @return
     */
    public VoucherOwnerConfig create(SimpleRequest request) {
        VoucherOwnerConfig voucherOwnerConfig = request.getO(VoucherOwnerConfig.class);
        return voucherOwnerConfigRepository.saveAndFlush(voucherOwnerConfig);
    }

    /**
     * 更新
     *
     * @param request
     * @return
     */
    public VoucherOwnerConfig update(SimpleRequest request) {
        VoucherOwnerConfig voucherOwnerConfig = request.getO(VoucherOwnerConfig.class);
        return voucherOwnerConfigRepository.saveAndFlush(voucherOwnerConfig);
    }

    /**
     * 删除
     *
     * @param request
     * @return
     */
    public String delete(SimpleRequest request) {
        VoucherOwnerConfig voucherOwnerConfig = voucherOwnerConfigRepository.findOne((String) request.get("id"));
        voucherOwnerConfigRepository.delete(voucherOwnerConfig.getId());
        return "删除成功";
    }

}
